from pyspark import SparkContext
import os
os.environ['PYSPARK_PYTHON'] = "python3"

sc = SparkContext(appName="Accumulator")

acc = sc.accumulator(0)

rdd = sc.parallelize((1,2,3,4,5,6,7))

rdd.foreach(lambda d: acc.add(d))

print(acc.value)
